package com.feizhi.inventory.fragment.itemdetails;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.aserbao.aserbaosandroid.functions.database.greenDao.db.DaoSession;
import com.aserbao.aserbaosandroid.functions.database.greenDao.db.TaskDao;
import com.aserbao.aserbaosandroid.functions.database.greenDao.db.TaskDetailsDao;
import com.feizhi.inventory.MainActivity;
import com.feizhi.inventory.R;
import com.feizhi.inventory.database.dbApp;
import com.feizhi.inventory.databinding.FragmentItemDetailsBinding;

/**
 * 物品详情
 * */
public class ItemDetailsFragment extends Fragment {
    private TaskDao taskDao;
    private FragmentItemDetailsBinding mBinding;
    private TaskDetailsDao taskDetailsDao;
    private MainActivity mActivity;
    private TextView titleText;

    public ItemDetailsFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mActivity = (MainActivity) getActivity();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        mBinding = FragmentItemDetailsBinding.inflate(getLayoutInflater());
        return mBinding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
        setOnClickListener();
    }

    private void setOnClickListener() {

    }

    private void initView() {


        DaoSession daoSession =((dbApp) mActivity.getApplication()).getDaoSession();
        taskDetailsDao = daoSession.getTaskDetailsDao();
        taskDao = daoSession.getTaskDao();


        titleText = mActivity.findViewById(R.id.title_text);
        titleText.setText("物品详情");

        Bundle bundle = getArguments();
        if (bundle != null) {
//            t_id : 任务ID
//            id : 物品编码
//            name : 物品名称
//            spec : 规格
//            epcID : epc编码
//            savePlace : 存放地
//            custodian : 保管人
//            department : 使用部门
//            stste : 状态
            mBinding.tvItemNumber.setText(bundle.getString("id"));
            mBinding.tvItemName.setText(bundle.getString("name"));
            mBinding.tvItemSpecifications.setText(bundle.getString("spec"));
            mBinding.tvPrintEncoding.setText(bundle.getString("eps_id"));
            mBinding.tvStorageAddress.setText(bundle.getString("save_place"));
            mBinding.tvCustodian.setText(bundle.getString("custodian"));
            mBinding.tvLlUserDepartment.setText(bundle.getString("department"));
            mBinding.tvLlUserState.setText(bundle.getString("state"));
            mBinding.tvLlUserNotes1.setText(bundle.getString("notes_1"));
            mBinding.tvLlUserNotes2.setText(bundle.getString("notes_2"));
            mBinding.tvLlUserNotes3.setText(bundle.getString("notes_3"));
            mBinding.tvItemType.setText(bundle.getString("type"));
            mBinding.tvLlUserInputDate.setText(bundle.getString("inputDate"));
        }


    }
}